package com.sinochem.yunlian.ship.common.enums;

import lombok.Getter;

/**
 * 动态类型
 */
public enum DynamicType {
    SHIPTRADE(0,"船舶交易"),
    SERVICE(1, "找服务"),
    RECRUIT(2, "招聘信息"),
    OTHER(99,"其他");

    @Getter
    private int code;
    @Getter
    private String name;

    DynamicType(int code, String name){
        this.code = code;
        this.name = name;
    }

    /**
     * 通过动态Code获取动态
     * @param code
     * @return
     */
    public static DynamicType getDynamicTypeByCode(Integer code) {
        for (DynamicType dynamicType : values()) {
            if (dynamicType.getCode()==code) {
                return dynamicType;
            }

        }
        return null;
    }

    /**
     * 通过动态Code获取动态名称
     * @param code
     * @return
     */
    public static String getDynamicNameByCode(Integer code) {
        for (DynamicType dynamicType : values()) {
            if (dynamicType.getCode()==code) {
                return dynamicType.getName();
            }

        }
        return null;
    }
}
